﻿@model RMS.Models.User

@{
    ViewBag.Title = "SelfDetails";
}

<h2>SelfDetails</h2>

<fieldset>
    <legend>User</legend>

    <div class="display-label">UserName</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.UserName)
    </div>

    <div class="display-label">Name</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Name)
    </div>
    <div class="display-label">Role(s)</div>
    <div class="display-field">
        @foreach (var role in Roles.GetRolesForUser())
        {
            <text> [ @role.ToString() ]</text>
        }
    </div>
    @if (!Roles.GetRolesForUser().Contains("Administrator"))
    {
        if (Model.CompanyId.HasValue)
        {   
            <text>
            <div class="display-label">Company</div>
            <div class="display-field">
            @Html.ActionLink(Model.Company.Name, "Details", "Company", new { id = Model.CompanyId.Value }, null)
            [ Founded by @Model.Company.FounderUser.Name ] [ Passcode: @Model.Company.PassCode ]
            </text>            
        }
        else
        {
            <br />
            using (Html.BeginForm("ApproveCompany", "User", FormMethod.Post))
            {
                @Html.Hidden("userId", Model.Id)
                
                <fieldset>
                <legend>Please Approve Yourself</legend>
                <div class="display-label">Company</div>
                <div class="display-field">
                    @Html.DropDownList("companyId", new SelectList(
                (IEnumerable<RMS.Models.Company>)ViewData["companies"], "Id", "Name"))
                </div>
            
                <div class="display-label">Passcode</div>
                <div class="display-field">
                    @Html.TextBox("passcode")
                </div>
                <p>
                    <input type="submit" value="submit" />
                </p>
                </fieldset>
            }
        }
    }
        <p>
        </p>
    </div>
</fieldset>
